package com.bw.liuyushan.zhuangao4_weektest2.MVP.Fragment;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import com.blankj.utilcode.util.ToastUtils;
import com.bumptech.glide.Glide;
import com.bw.liuyushan.mvp_lib.View.BaseFragment;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Activity.UserActivity;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Contrack.IContrackTest;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Model.BaseModelTest;
import com.bw.liuyushan.zhuangao4_weektest2.MVP.Presenter.BasePresenterTest;
import com.bw.liuyushan.zhuangao4_weektest2.R;

import org.greenrobot.eventbus.EventBus;

/**
 * ZhuanGao4_WeekTest2
 * file name is : Fragment_Main1
 * created by Ender on 2021/8/23 8:31.
 * author : 刘雨杉
 * Describe(作用):
 */
public class Fragment_Main5 extends BaseFragment<BasePresenterTest> implements IContrackTest.C_ViewTest {
    private Button cleansp;
    private ImageView imgGif;

    @Override
    public int bindLayout() {
        return R.layout.fragment_main5;
    }

    @Override
    public void initView() {
        //防止内存泄露
        ip = new BasePresenterTest(new BaseModelTest(), this);


        cleansp = (Button) findViewById(R.id.cleansp);
        imgGif = (ImageView) findViewById(R.id.img_gif);
    }

    @Override
    public void initDate() {
        Glide.with(getContext()).load(R.drawable.headbackgroud).into(imgGif);
        cleansp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                SharedPreferences sp = getActivity().getSharedPreferences("sp", Context.MODE_PRIVATE);
                SharedPreferences.Editor edit = sp.edit();
                edit.clear();
                edit.commit();
                ToastUtils.showShort("您已退出登录!");
                EventBus.getDefault().postSticky("再次登录");
                Intent intent = new Intent(getActivity(), UserActivity.class);
                startActivity(intent);

            }
        });

    }
}
